package com.yuyu.commons.mq.ons;

import com.aliyun.openservices.ons.api.ONSFactory;
import com.aliyun.openservices.ons.api.Producer;
import com.aliyun.openservices.ons.api.PropertyKeyConst;
import com.aliyun.openservices.ons.api.bean.ProducerBean;
import com.yuyu.commons.constant.AliMqPropertiesConstant;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @author ons producer
 * @version 1.0
 * @description: TODO
 * @date 2022/8/2 10:53
 */
@Configuration
public class OnsProducer {

    @Bean(initMethod = "start",destroyMethod = "shutdown")
    public static ProducerBean getProduce(){
        Properties properties = new Properties();
        properties.put(PropertyKeyConst.GROUP_ID, AliMqPropertiesConstant.groupId);
        properties.put(PropertyKeyConst.NAMESRV_ADDR, AliMqPropertiesConstant.nameSrvAddress);
        properties.put(PropertyKeyConst.SecretKey,AliMqPropertiesConstant.secretKey);
        properties.put(PropertyKeyConst.AccessKey,"1dasdas11515");
        ProducerBean producerBean = new ProducerBean();
        producerBean.setProperties(properties);
        return producerBean;
    }
}
